/**
 *<p>Copyright: CHINA NATIONAL SOFTWARE & Manager CO.,LTD.</p>
 */
package com.cssnb.wwxt.qx.action;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cssnb.commons.utils.CharsetUtils;
import com.cssnb.commons.utils.ParameterMap;
import com.cssnb.commons.utils.page.PageUtils;
import com.cssnb.wwxt.qx.service.QxModuleManager;

/**
 * @Company: 中国软件与技术服务股份有限公司宁波子公司
 * @Project: 宁波市国税-外维系统
 * @Module ID:
 * @Description:
 * @JDK version used: JDK1.6
 * @Author: 卜繁晟
 * @Email: 5545795@qq.com | bufsh@css.com.cn
 * @Created Date: 2013-4-19 下午4:57:35
 */
@Controller
@RequestMapping("/qx/module")
@SuppressWarnings({ "unused", "unchecked", "rawtypes" })
public class QxModuleController {

	@Autowired
	QxModuleManager qxModuleManager;

	@RequestMapping({ "/index", "/", "" })
	public String index(HttpServletRequest request, HttpServletResponse response){
		Map pMap = ParameterMap.getParameterMap(request);
		request.setAttribute("pMap", CharsetUtils.getEncodingMap(pMap, "iso-8859-1", "GBK"));
		return "qx/module/index";
	}
	/**
	 * 添加页面跳转
	 * @Author: 卜繁晟
	 * @Created Date: 2013-5-7 上午10:09:35
	 */
	@RequestMapping("/toAdd")
	public String toAdd(HttpServletRequest request, HttpServletResponse response){
		return "qx/module/add";
	}
	/**
	 * 添加
	 * @Author: 卜繁晟
	 * @Created Date: 2013-5-7 上午10:09:30
	 */
	@RequestMapping("/add")
	public String add(HttpServletRequest request, HttpServletResponse response) throws IOException{
		Map pMap = ParameterMap.getParameterMap(request);
		response.setContentType("text/html;charset=utf-8;");
		response.getWriter().print("1");
		return null;
	}
	/**
	 * 参数传递，修改页面跳转
	 * @Author: 卜繁晟
	 * @Created Date: 2013-5-7 上午10:09:06
	 */
	@RequestMapping("/toUpd")
	public String toUpd(HttpServletRequest request, HttpServletResponse response){
		Map pMap = ParameterMap.getParameterMap(request);
		Map module = qxModuleManager.getModule(pMap);
		request.setAttribute("module", CharsetUtils.getEncodingMap(module, "iso-8859-1", "GBK"));
		return "qx/module/upd";
	}
	/**
	 * 修改
	 * @Author: 卜繁晟
	 * @Created Date: 2013-5-7 上午10:09:00
	 */
	@RequestMapping("/upd")
	public String upd(HttpServletRequest request, HttpServletResponse response) throws IOException{
		Map pMap = ParameterMap.getParameterMap(request);
		response.setContentType("text/html;charset=utf-8;");
		response.getWriter().print("1");
		return null;
	}
	/**
	 * 删除
	 * @Author: 卜繁晟
	 * @Created Date: 2013-5-7 上午11:29:13
	 */
	@RequestMapping("/del")
	public String del(HttpServletRequest request, HttpServletResponse response) throws IOException{
		Map pMap = ParameterMap.getParameterMap(request);
		response.setContentType("text/html;charset=utf-8;");
		response.getWriter().print("1");
		return null;
	}
	@RequestMapping("/search")
	public String search(HttpServletRequest request, HttpServletResponse response){
		Map pMap = ParameterMap.getParameterMap(request);
		int moduleCount = qxModuleManager.getModuleCount(pMap);
		pMap.putAll(PageUtils.getPageInfo(request, moduleCount));
		List moduleList = qxModuleManager.getModuleList(pMap);
		request.setAttribute("moduleList", CharsetUtils.getEncodingList(moduleList, "iso-8859-1", "GBK"));
		return "qx/module/list";
	}
	@RequestMapping("/form")
	public String form(HttpServletRequest request, HttpServletResponse response){
		Map pMap = ParameterMap.getParameterMap(request);
		Map qxModuleInfo = qxModuleManager.getModule(pMap);
		request.setAttribute("qxModule", CharsetUtils.getEncodingMap(qxModuleInfo, "iso-8859-1", "GBK"));
		return "qx/module/form";
	}
}